package main

import (
	"io"
	"log"
	"net/http"
)

type a struct{}

func (*a) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	path := r.URL.String() //获得访问的路径
	switch path {
	case "/":
		io.WriteString(w, "<h1>root</h1><a href=\"abc\">abc</a>")
	case "/abc":
		io.WriteString(w, "<h1>abc</h1><a href=\"/\">root</a>")
	}
}

func main() {
	err := http.ListenAndServe(":8080", &a{})
	if err != nil {
		log.Println(err.Error())
	}
}
